import Vue from "vue"

function date(v) {
    const time = new Date(v);
    return time.getFullYear()+"-"+
        (time.getMonth()+1).toString().padStart(2,0)+"-"+
        time.getDate().toString().padStart(2,0)+" "+
        time.getHours().toString().padStart(2,0)+":"+
        time.getMinutes().toString().padStart(2,0)+":"+
        time.getSeconds().toString().padStart(2,0);
}
function currency(v,options) {
    const {num=2,money="￥"}=options ||{}
    return money+v.toFixed(num)
}
function imgUrl(v) {
    // return "/api/"+v;
    return "http://127.0.0.1/"+v
}
export const filters={
    currency,
    date,
    imgUrl
}

for(let key in filters){
    Vue.filter(key,filters[key])
}
